package com.jiuqi.bi.irp.server.launch;

import com.jiuqi.bi.irp.core.manager.DomainLabelManager;
import com.jiuqi.bi.log.manager.BILogger;
import com.jiuqi.bi.server.bsp.tagmanagement.manager.TagManager;

import javax.sql.DataSource;
import java.sql.Connection;

/**
 * 将下列字段对应内容转成大写
 * 表名：BSP_TAG             字段名：TAG_CODE
 * 表名：IRP_DOMAIN_LABEL    字段名：L_CODE
 */
public class BSPTagModuleUpdateExecutor {
    private static BILogger logger = BILogger.getBILogger(BSPTagModuleUpdateExecutor.class);

    public void execute(DataSource dataSource) throws Exception {
        try (Connection conn = dataSource.getConnection()) {
            doExecute(conn);
        }
    }

    public void doExecute(Connection connection) {
        try {
            TagManager tagManager = new TagManager();
            tagManager.capitalizeLCodeField(connection);

            DomainLabelManager domainLabelManager = new DomainLabelManager();
            domainLabelManager.capitalizeLCodeField(connection);
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("标签编码批量转大写操作失败", e);
        }
    }

}
